<?php
// 直接修复：将admin菜单的node改为plugin-admin格式
$host = '127.0.0.1';
$port = 3306;
$database = 'qiandao';
$username = 'root';
$password = 'root';

try {
    $pdo = new PDO("mysql:host={$host};port={$port};dbname={$database};charset=utf8mb4", $username, $password);
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    
    echo "开始修复admin菜单的node...\n\n";
    
    // 将 admin/ 改为 plugin-admin/
    $stmt = $pdo->prepare("UPDATE system_menu SET node = REPLACE(node, 'admin/', 'plugin-admin/') WHERE node LIKE 'admin/%'");
    $stmt->execute();
    $count = $stmt->rowCount();
    
    echo "✓ 已更新 {$count} 个菜单的node\n\n";
    
    // 验证
    echo "=== 验证更新后的菜单 ===\n\n";
    $stmt = $pdo->query("SELECT id, title, node FROM system_menu WHERE node LIKE 'plugin-admin/%'");
    $menus = $stmt->fetchAll(PDO::FETCH_ASSOC);
    
    foreach ($menus as $menu) {
        echo "ID:{$menu['id']} {$menu['title']} - {$menu['node']}\n";
    }
    
} catch (PDOException $e) {
    echo "错误: " . $e->getMessage() . "\n";
}

